package com.mall.goods.dao;

import com.mall.pojo.Brand;
import com.mall.pojo.Spec;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author: bamboo_shoot on 20/5/20
 * @description: -
 */

public interface BrandMapper extends Mapper<Brand> {
    /**
     * 查询品牌列表
     *
     * @param: [category]分类名称
     * @return: java.util.List<com.mall.pojo.Brand>
     */
    @Select("SELECT tb.* FROM tb_brand tb INNER JOIN " +
            "tb_category_brand tcb on tb.id=tcb.brand_id INNER JOIN tb_category tc on tc.id=tcb.category_id " +
            "WHERE tc.name=#{name} ORDER BY seq DESC")
    List<Brand> searchBrandByCategoryName(@Param("name") String category);

    /**
     * 根据分类名称查询规格
     *
     * @param: [category]
     * @return: java.util.List<com.mall.pojo.Spec>
     */
    @Select("SELECT ts.* FROM tb_category tc " +
            "INNER JOIN tb_template tt on tt.id=tc.template_id " +
            "INNER JOIN tb_spec ts on ts.template_id = tt.id WHERE tc.name=#{name}")
    List<Spec> searchSpecificationByCategoryName(@Param("name") String category);
}
